In This Part
by K. David White
In This Chapter
ActiveX and OLE seem to be in the forefront of application development news these days. These technologies, however, are driven from a base specification referred to as Component Object Model (COM). COM, COM, everywhere COM! It appears that everything is becoming active. From desktop applications working with compound documents to the current desktop, you find this technology as a major focus of Microsofts direction. Object-oriented programming has been around for some time now, but COM still cant simply be defined as another implementation. It is much more than that.
The COM specification describes a methodology for implementing compon ents: reusable objects that can be attached in different ways to create different applications. Obviously, if you are reading this book, you are familiar with the C++ representation of object-oriented programming. In the interest of doing it better, you are always looking for better and more efficient ways to solve software development problems. One such approach is reuse.
Reuse has been a hot topic for some time. Think of a manufacturing process that simply takes parts out of inventory, moves them to stations along the manufacturing line, and then assembles them in order, making a usable product. The software industrys desire for a similar manufacturing paradigm also provides the thrust behind a reusable solution to software development. As hardware technology has progressed, so has the process of developing software. I could ramble on and on about the benefits and disadvantages of object reuse, but lets take an inside look at this amazingly simple yet paradoxically complex method of reusability.
Long ago and far away (okay, so its Redmond and was only a few years ago), there was OLE 1. Object linking and embedding was developed primarily to support compound documents. OLE provides an application with the capability to contain and manipulate a document that was produced by another application as if it were its own. Thus a compound document could give the appearance of a single entity. This integration provided a large boost to the productivity of the users of these applications. No longer did a user have to use two applications to work with a single set of information; to the user it appeared as if only one application was performing the work.
Then along came OLE 2, which was a marked improvement not only in functionality, but also in performance. OLE 1 was simply a methodology to solve a unique problem, but it didnt go far enough in solving the bigger problem of reusable objects. OLE 2 was aimed at creating a way for objects to communicate with each other in a consistent and reliable manner.
Microsoft decided to drop OLE as an abbreviation, as well as any future version numbers, and to simply call the technology OLE. No longer was OLE to represent object linking and embedding and compound documents, but was used to represent any application that was COM-based. Well, Microsoft wasnt finished with its marketing terminology switcharoo. In 1996, ActiveX was born, or was it? Was this another name for OLE/COM, or was this something entirely different? It appeared that ActiveX was used to refer to Internet technologies, although in fact ActiveX replaced the former VBX components. 16-bit Visual Basic had a mechanism for incorporating extension controls, which was well-known but not formally specified. ActiveX changed that while at the same time providing Microsoft with a portable Internet control methodology. ActiveX was, in fact, a derivative technology based on a central coreCOM. Today, other technologies have followed a similar development theme, such as DirectX (see Chapter 30, MFC and DirectX).
Because COM terminology was so interchangeable, OLE now refers only to object linking and embedding. ActiveX refers mainly to visual components used in developing user-interface extensions to applications or Web pages. But the underlying technology that binds all this terminology is COM.
COM provides the capability for one subset of an application to communicate not only with another subset of the same application, but also with a subset of a different application. This interchangeability is the goal of object-oriented application development: Creating reusable components that can not only be plugged in by applications to perform work, but that can also communicate with other components is exactly what COM has accomplished. COM does this by supporting one or more interfaces that other applications and objects can use to access the components internal methods.
If youre new to COM, some of the terminology might be a little confusing. Hopefully, you are not new to object-oriented terminology. In the following sections, I will explain some of the terms I will be using to define this technology.
Interfaces
An interface is defined as an exposed connection for a controlling application to access a COM object. Heres what a COM interface is not:
There can be multiple interfaces for one COM object. In fact, COM objects normally do support more than one interface.
Interfaces are immutable. The COM specification dictates that COM interfaces cannot be versioned. Interface version conflicts are avoided by creating entirely new interfaces for even the most minor modification to the original interface.